package com.num2.controller.wly;

import javax.annotation.Resource;
import javax.servlet.http.HttpSession;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import com.num2.model.wly.BalanceChartModel;
import com.num2.model.wly.RichListChartModel;
import com.num2.service.wly.ChartService;

@Controller
public class ChartCtrl {
	@Resource
	ChartService bcs;
	
	@RequestMapping("/balanceChart")
	public String getChart(HttpSession s,Model m){
		Integer user_id = (Integer) s.getAttribute("user_id");
		//得到service层的数据
		BalanceChartModel bcm = bcs.getBalanceChart(user_id);
		m.addAttribute("transaction_date",bcm.getjDate());
		m.addAttribute("balance",bcm.getBalance());
		System.out.println(bcm.toString());
		return "demo/chart";
	}
	
	@RequestMapping("/richListChart")
	public String richListChart(Model m){
		RichListChartModel rlcm= bcs.getRichListChart();
		m.addAttribute("user_id", rlcm.getjUser_id());
		m.addAttribute("balance",rlcm.getjBalance());
		m.addAttribute("name",rlcm.getjName());
		System.out.println(rlcm.toString());
		return "demo/adminChart";
	}

	public ChartService getBcs() {
		return bcs;
	}

	public void setBcs(ChartService bcs) {
		this.bcs = bcs;
	}
	
}
